package com.gmadmin.controller;

import com.gmadmin.mq.template.TestMessageTemplate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhangliang
 * @version 1.0
 * @date 2022/7/28 13:04
 * mq测试
 */
@Api(tags = "test:mq")
@RequestMapping("/api/mq/test")
@RestController
public class MqTestController {

    private final TestMessageTemplate testMessageTemplate;

    public MqTestController(TestMessageTemplate testMessageTemplate) {
        this.testMessageTemplate = testMessageTemplate;
    }

    @ApiOperation(value = "发送同步消息")
    @PostMapping("sync")
    public void syncSend() {
//        for (int i = 0; i < 1; i++) {
        testMessageTemplate.syncSendTest(String.valueOf(0), "message" + 0);
//        }
    }

    @ApiOperation(value = "发送事务消息")
    @PostMapping("transaction")
    public void sendMessageForTransaction() {
//        for (int i = 0; i < 1; i++) {
        testMessageTemplate.sendMessageForTransaction(String.valueOf(0), "message" + 0);
//        }
    }

}
